package com.qd.common.panda.domain.entity.transfer;

import com.cdqidi.valid.group.DefaultGroup;
import lombok.Data;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.List;
import java.util.Optional;

/**
 * 转账信息
 *
 * @author sjk
 * @create 2023-09-07 11:32
 * @since 1.0.0
 */
@Data
@Accessors(chain = true)
public class TransferDTO {
    private List<Transfer> list;
    public void freeData(){
        Optional.ofNullable(list).ifPresent(List::clear);
    }

    @Data
    @Accessors(chain = true)
    public static class Transfer {
        /**
         * 用户ID
         */
        @NotBlank(message = "用户ID不能为空", groups = DefaultGroup.class)
        @Size(max = 50, message = "用户ID长度不能超过{max}位", groups = DefaultGroup.class)
        private String userId;
        /**
         * 转账金额
         */
        @NotBlank(message = "转账金额不能为空", groups = DefaultGroup.class)
        @Size(max = 8, message = "转账金额长度不能超过{max}位", groups = DefaultGroup.class)
        private String transferAmount;

        public void freeData() {
            this.userId = null;
            this.transferAmount = null;
        }
    }
}
